﻿# -*- coding:utf-8 -*-
from django.forms import ModelForm
from django import forms
from django.contrib.auth.models import User
from homesite.files.models import File, Category



class FileForm(ModelForm): 

    name = forms.FileField(widget=forms.FileInput(attrs={'size':'62'}), label='Файл')
    
    class Meta:
        model = File 
        exclude = ('user', 'name_real', 'mimetype', 'download_cnt', 'category')
        
        
        
class FileEditForm(ModelForm):         

    category =  forms.ModelChoiceField(Category.objects.all(), label='Категория')
    title = forms.CharField(max_length=64, widget=forms.TextInput(attrs={'size':'80'}), label='Название')
    description = forms.CharField(max_length=512, widget=forms.Textarea, required=False, label='Описание') 

 

class CategoryCreateForm(ModelForm):    
     
    class Meta:
        model = Category
        exclude = ('parent', 'files_count')



class CategoryEditForm(ModelForm):        
  
    title = forms.CharField(max_length=32, widget=forms.TextInput(attrs={'size':'80'}), label='Название')

    class Meta:
        model = Category    
        exclude = ('files_count')
        